package com.money.tracker.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.money.tracker.auth.entity.SysUserRole;
import com.money.tracker.auth.mapper.SysUserRoleMapper;
import com.money.tracker.auth.service.ISysUserRoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 用户和角色关联表 服务实现类
 * </p>
 *
 * @author zhangshuai
 * @since 2024-09-27
 */
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements ISysUserRoleService {

    @Override
    public List<Long> listByUserId(Long userId) {
        // 获取用户角色对应关系
        LambdaQueryWrapper<SysUserRole> sysUserRoleLambdaQueryWrapper = new LambdaQueryWrapper<SysUserRole>()
                .eq(SysUserRole::getUserId, userId);
        return this.list(sysUserRoleLambdaQueryWrapper).stream()
                .map(SysUserRole::getRoleId)
                .toList();
    }
}
